
import java.io.File;

public class Etc {

    public static void main(String[] argv){
        try {
            File dir = new File(argv[0]);
            if ("etc".equals(dir.getName())){
                System.out.println(dir.getPath());
                System.exit(0);
            }
            else {

                for (int cc = 0; cc < 5; cc++){

                    File etc = new File(dir,"etc");

                    if (etc.isDirectory()){
                        System.out.println(etc.getPath());
                        System.exit(0);
                        return;
                    }
                    else {
                        dir = dir.getParentFile();
                    }
                }
                System.err.println("Directory not found: 'etc'.");
                System.exit(1);
            }
        }
        catch (Exception exc){
            exc.printStackTrace();
            System.exit(1);
        }
    }
}
